package com.ushine.web.component.excel.handler;

import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl;
import cn.hutool.core.util.StrUtil;
import com.ushine.web.component.excel.model.MemberDO;


/**
 * @Author: yls
 * @Date 2021/10/26 14:38
 * @Description: 自定义字段处理
 * @Version 1.0
 **/
public class MemberExcelDataHandler extends ExcelDataHandlerDefaultImpl<MemberDO> {

    @Override
    public Object exportHandler(MemberDO obj, String name, Object value) {
        if ("昵称".equals(name)) {
            String emptyValue = "暂未设置";
            if (value == null) {
                return super.exportHandler(obj, name, emptyValue);
            }
            if (value instanceof String && StrUtil.isBlank((String) value)) {
                return super.exportHandler(obj, name, emptyValue);
            }
        }
        return super.exportHandler(obj, name, value);
    }

    @Override
    public Object importHandler(MemberDO obj, String name, Object value) {
        return super.importHandler(obj, name, value);
    }
}
